package influx

import client "github.com/influxdata/influxdb1-client/v2"

type Result []client.Result

func (this Result) GMap1() []map[string]interface{} {
	list := []map[string]interface{}{}
	if len(this) > 0 {
		for _, k := range this[0].Series {
			for _, x := range k.Values {
				m := map[string]interface{}{}
				for i, y := range k.Columns {
					if len(x) > i {
						m[y] = x[i]
					}
				}
				list = append(list, m)
			}
		}
	}
	return list
}

func (this Result) GMaps() [][]map[string]interface{} {
	lists := [][]map[string]interface{}{}
	for _, v := range this {
		list := []map[string]interface{}{}
		for _, k := range v.Series {
			for _, x := range k.Values {
				m := map[string]interface{}{}
				for i, y := range k.Columns {
					if len(x) > i {
						m[y] = x[i]
					}
				}
				list = append(list, m)
			}
		}
		lists = append(lists, list)
	}
	return lists
}
